//
// Created by Administrator on 2017/8/4.
//

#ifndef AUTOMAHJONG_TEMPLATE_H
#define AUTOMAHJONG_TEMPLATE_H

#include <string>
#include <vector>
#include "Define.h"
#include "../image/Image.h"
#include "../image/EditImage.h"

using namespace std;
using namespace img;
using namespace utils;

namespace mahjong {
    /**
     * 扫描位置
     */
    class ScanPos {
    public:
        ScanPos(short x, short y);

        ScanPos(short x, short y, short x1, short y1);

        short getX() const;

        short getY() const;

        short getOffsetX() const;

        short getOffsetY() const;

    protected:
        short mX;
        short mY;
        short mOffsetX;
        short mOffsetY;
    };


    /*
    *图像模板项
    */
    class Item {
    public:
        Item(string path, string maskPath, uint8_t binary, MahjongEnum value, ImageChannel channel);

        Item(const Prt<Image> &mTempl, const Prt<Image> &mMask, uint8_t mBinary, MahjongEnum mValue,
             ImageChannel mChannel);

        uint8_t getBinary();

        Prt<Image> &getTempl();

        Prt<Image> &getask();

        MahjongEnum getValue();

        ImageChannel getChannel();

    protected:
        uint8_t mBinary;                //二值化
        Prt<Image> mTempl;                   //模板
        Prt<Image> mMask;                    //蒙板;
        MahjongEnum mValue;                    //对应值
        ImageChannel mChannel;          //通道
    };

    class Template {
    public:
        Template();

        Prt<Item> &getMTong();

        Prt<Item> &getMTiao();

        Prt<Item> &getMWan();

        Prt<Item> &getMZhuang();

        vector<Prt<Item>> &getMeBoard();

        vector<Prt<Item>> &getMeOutBoard();

        vector<Prt<Item>> &getTopBoard();

        vector<Prt<Item>> &getUpBoard();

        vector<Prt<Item>> &getDownBoard();

        vector<ScanPos> &getScanUpOut();

        vector<ScanPos> &getScanDownOut();

        vector<ScanPos> &getScanMeOut();

        vector<ScanPos> &getScanTopOut();

        vector<ScanPos> &getScanUp();

        vector<ScanPos> &getScanDown();

        vector<ScanPos> &getScanMe();

        vector<ScanPos> &getScanTop();

        vector<Prt<Item>> &getMeOpenBoard();

        Rect &getTopLack();

        Rect &getUpLack();

        Rect &getDownLack();

        Rect &getMeLack();

        Rect &getDownDealer();

        Rect &getMeDealer();

        Rect &getUpDealer();

        Rect &getTopDealer();

        vector<ScanPos> &getMScanMeOpen();

    private:
        Prt<Item> mMTong; //筒
        Prt<Item> mMTiao; //条
        Prt<Item> mMWan;  //万
        Prt<Item> mMZhuang;  //庄

        vector<Prt<Item>> mMeOpenBoard;         //自己拥有牌模板
        vector<Prt<Item>> mMeBoard;             //自己拥有牌模板
        vector<Prt<Item>> mMeOutBoard;            //自己已出牌模板
        vector<Prt<Item>> mTopBoard;            //对家牌模板
        vector<Prt<Item>> mUpBoard;             //上家牌模板
        vector<Prt<Item>> mDownBoard;           //下家牌模板

        vector<ScanPos> mScanUpOut;
        vector<ScanPos> mScanDownOut;
        vector<ScanPos> mScanMeOut;
        vector<ScanPos> mScanTopOut;

        vector<ScanPos> mScanUp;
        vector<ScanPos> mScanDown;
        vector<ScanPos> mScanTop;
        vector<ScanPos> mScanMeOpen;

        Rect mTopLack;
        Rect mUpLack;
        Rect mDownLack;
        Rect mMeLack;
        Rect mDownDealer;
        Rect mMeDealer;
        Rect mUpDealer;
        Rect mTopDealer;
    };

};


#endif //AUTOMAHJONG_TEMPLATE_H
